package com.moon.robot.service;

import com.forte.qqrobot.anno.depend.Beans;
import com.forte.qqrobot.anno.depend.Depend;
import com.moon.robot.Utils.Utils;
import com.moon.robot.mapper.KeyMapper;
import com.moon.robot.pojo.KeyCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


import java.util.Date;
import java.util.List;

@Beans
@Component
public class KeyServiceImpl implements KeyService{
    @Autowired
    KeyMapper keyMapper;


    @Override
    public List<String> selKey(String key) {
        return keyMapper.selKey(key);
    }

    @Override
    public String addKey(String qq) {
        String key = Utils.getRandomStr(6);
        KeyCode keyCode = new KeyCode(key,qq,new Date());
        keyMapper.addKey(keyCode);
        return key;
    }

    @Override
    public Integer delKey(String key) {
        return keyMapper.delKey(key);
    }
}
